<template>
  <div>
    <!-- 下拉筛选 -->
    <evaluate-menu
      ref="evaluateMenu"
      :showCompleted="true"
      :taskId="detailsData.id"
      @getEvalResult="dealEvalChainInfo"></evaluate-menu>

    <div class="eval-unit" v-if="allEvalUserList.length">
      <evaluate-row v-for="mainOrg in allEvalUserList" :key="mainOrg.id" :org="mainOrg"></evaluate-row>
    </div>
    <!-- 
      主办单位
    <div class="eval-unit" v-if="mainOrgs.length">
      <div class="eval-name">主办单位({{ mainOrgs.length }}) :</div>
      <evaluate-row v-for="mainOrg in mainOrgs" :key="mainOrg.id" :org="mainOrg"></evaluate-row>
    </div>
     协办单位
    <div class="eval-unit" v-if="subOrgs.length">
      <div class="eval-name">协办单位({{ subOrgs.length }}) :</div>
      <evaluate-row v-for="subOrg in subOrgs" :key="subOrg.id" :org="subOrg"></evaluate-row>
    </div> -->
    <van-empty description="暂无数据" v-if="totalListNum === 0" />
  </div>
</template>
<script>
import EvaluateRow from '../components/EvaluateRow.vue'
import EvaluateMenu from '../components/EvaluateMenu.vue'

export default {
  name: 'TaskReview',
  components: { EvaluateRow, EvaluateMenu },
  props: {
    // 详情
    detailsData: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      mainOrgs: [], // 主办统计
      subOrgs: [], // 协办统计
    }
  },
  computed: {
    totalListNum() {
      return this.mainOrgs.length + this.subOrgs.length
    },
    // 产品化 部分牵头和协同，统一展示数据合并
    allEvalUserList() {
      return [...this.mainOrgs, ...this.subOrgs]
    },
  },
  methods: {
    initdata() {
      this.$refs.evaluateMenu.initEvalCycleNper()
    },
    dealEvalChainInfo(data) {
      const { evaluationState = '', leaderEvaluationDetailVOS = [], coEvaluationDetailVOS = [] } = data
      /* 只展示已完成的 */
      if (evaluationState === '2') {
        this.mainOrgs = leaderEvaluationDetailVOS || []
        this.subOrgs = coEvaluationDetailVOS || []
      } else {
        this.mainOrgs = []
        this.subOrgs = []
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.van-notice-bar {
  border-top: 1px solid #eee;
}
.van-notice-bar--wrapable {
  padding: 8px 16px;
}
.eval-unit {
  background: #fff;
  padding: px2rem(30) px2rem(20);
  margin-top: px2rem(20);
  .eval-name {
    font-size: $fontSize30;
    position: relative;
    padding-left: px2rem(15);
    font-weight: 600;
    &::after {
      content: '';
      width: 3px;
      height: 20px;
      background: #d81e06;
      position: absolute;
      top: px2rem(12);
      left: 0;
    }
  }
}
</style>
